package com.jyniubi.core.controller.admin;


import com.jyniubi.base.result.R;
import com.jyniubi.core.pojo.entity.Lend;
import com.jyniubi.core.service.LendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 标的准备表 前端控制器
 * </p>
 *
 * @author jyzhang
 * @since 2024-04-27
 */
@RestController
@RequestMapping("/admin/core/lend")
@Api(tags = "标的管理")
public class AdminLendController {
    @Resource
    LendService lendService;
    @ApiOperation("放款")
    @PutMapping("/makeLoan/{id}")
    public R makeLoan(@PathVariable("id")String id){
        lendService.makeLoan(id);
        return R.ok().msg("放款成功");
    }

    @ApiOperation("标的列表")
    @GetMapping("/getLendList")
    public R getLendList(){
        List<Lend> lends = lendService.getLendList();
        return R.ok().data("items",lends);
    }

    @ApiOperation("标的详情")
    @GetMapping("/getLendDetail/{id}")
    public R getLendDetail(@PathVariable("id")String id){
        Map<String,Object> map = lendService.getLendDetail(id);
        return R.ok().data("items",map);
    }
}

